package leetcodecompetition.S114AC;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Siantar
 * @Date: 2023-09-30-22:40
 * @Description: 1.0
 */
public class T100032 {
    public int minOperations(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            map.put(num, map.getOrDefault(num, 0) + 1);
        }
        int res = 0;
        for (Map.Entry e : map.entrySet()) {
            if ((int)e.getValue()==1)return -1;
            res += ((int) e.getValue() + 2) / 3;
        }
        return res;
    }
}
